﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Banner.ascx.cs" Inherits="Admin_Components_MasterData_Banner" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<telerik:RadScriptManager ID="ScriptManager2" runat="server" EnableTheming="True"></telerik:RadScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="form-horizontal wrapper-center clearfix">
         <!--Block bên trái -->
            <div class="form-group col-md-6">
                <!--Dòng -->
                <div class="form-group">
            <label class="col-md-4 control-label">
                Tiêu đề</label>
            <div class="col-md-8">
                <telerik:RadTextBox ID="txtTitle" CssClass="col-imp-8 inputForm"  runat="server"  />
            </div>
        </div>
            <!--End Dòng -->
            <!--Dòng -->
        <div class="form-group">
            <label class="col-md-4 control-label">Hình ảnh(732x245)<span style="color:red;">(*)</span></label>
            <div class="col-md-8">
                <asp:FileUpload ID="fuImagePath" CssClass="col-imp-10 inputForm"  runat="server"   />
                <asp:RegularExpressionValidator ID="REVUploadFile" runat="server"
                                    ControlToValidate="fuImagePath" 
                                    ErrorMessage="Chỉ được upload file dạng .gif, .jpg, .jpeg, .png"
                                    ValidationExpression="^.+\.((gif)|(jpg)|(jpeg)|(PNG)|(png)|(GIF)|(JPG)|(JPEG)|(swf))$"
                                    ValidationGroup="g1"></asp:RegularExpressionValidator>
                <asp:HiddenField ID="hidOldImagePath" runat="server" />
                </div>
        </div>
        <!--End Dòng -->
                <!--Dòng -->
                <div class="form-group">
                <label class="col-md-4 control-label">Thứ tự hiển thị</label>
                <div class="col-md-5">
                    <telerik:RadTextBox ID="txtSortOrder" CssClass="col-imp-2 inputForm" Width="20px" runat="server"  onkeyup = "FormatNumber(this)" />
                    </div>
                </div>
                <!--End Dòng -->
                
                <!--Dòng -->
                <div class="form-group">
                    <label class="col-md-3 control-label"></label>
                    <div class="col-md-5"></div>
                </div>
                <!--End Dòng -->
                </div>
                 <!--End Block bên trái -->
                 <!--Block bên phải -->
                <div class="form-group col-md-6">
                    <%--<!--Dòng -->
                     <div class="form-group">
                        <label class="col-md-3 control-label">Người cập nhật</label>
                        <div class="col-md-8">
                           <telerik:RadTextBox ID="txtLastUpdatedBy" CssClass="col-imp-4 inputForm" Width="40px" runat="server"   Enabled ="false"/>
                         </div>
                    </div>
                    <!--End Dòng -->
                     <!--Dòng -->
                     <div class="form-group">
                        <label class="col-md-3 control-label">Ngày cập nhật</label>
                        <div class="col-md-8">
                           <telerik:RadTextBox ID="txtLastUpdatedDateTime" CssClass="col-imp-4 inputForm" Width="40px" runat="server"   Enabled ="false"/>
                         </div>
                    </div>
                    <!--End Dòng -->--%>
                </div>
                 <!--End Block bên phải -->
      </div>
    <!--Action-->
            <div class="set-btns text-center">           
                <asp:Button ID="btnSave" CssClass="btn btn-sm btn-primary" runat="server" Text="Lưu"  OnClick="btnSave_Click" ValidationGroup="g1" />
                <%--<asp:Button ID="btnCancel" runat="server" CssClass="btn btn-sm btn-warning" Text="Xóa"  OnClick="btnCancel_Click" OnClientClick="return ConfirmOnDelete('Bạn chắc chắn muốn xóa không?')" />--%>
                <asp:Button ID="btnNew" CssClass="btn btn-sm btn-primary" runat="server" Text="Tạo mới"  OnClick="btnNew_Click" />
            </div>
            <!--End Action -->
             <!--Grid data-->
            <div class="row">
               <div style="float: left;font-weight:bold" runat="server" id="div_TotalRows" >&nbsp;Kết quả tìm kiếm: 0</div>
            <telerik:radgrid id="gvData" runat="server" cellspacing="0" cssclass=" table table-bordered"
                gridlines="None" autogeneratecolumns="False" headerstyle-horizontalalign="Center" PageSize="10" AllowCustomPaging="true"
                allowmultirowselection="True" headerstyle-borderstyle="None"  ShowHeader="true" Height="250" OnNeedDataSource="gvData_NeedDataSource"  OnItemCommand="gvData_ItemCommand">
                
                <MasterTableView ShowHeader="true" NoMasterRecordsText="Không có dữ liệu." ShowGroupFooter="true" AllowPaging="True" PageSize="10" EditMode="InPlace">
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
                 <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="STT" DataField="RowID" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <%# Eval("RowID") %></ItemTemplate>
                        <HeaderStyle Width="30px" />
                        <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn  DataField="Title" UniqueName="Title"  ReadOnly="true" HeaderText="Tiêu đề">
                        <HeaderStyle HorizontalAlign="Center"  Width="80px" />
                        <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridBoundColumn>
                      <telerik:GridTemplateColumn HeaderText="Hình ảnh" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                                <asp:Image runat="server"  Width="732px" Height ="150px" ID="Image1" ImageUrl='<%# Eval("ImagePath") %>' ></asp:Image>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="732px"  />
                        <ItemStyle HorizontalAlign="Left"  />
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn  DataField="SortOrder" UniqueName="SortOrder"  ReadOnly="true" HeaderText="Vị trí hiển thị">
                        <HeaderStyle HorizontalAlign="Center"  Width="50px" />
                        <ItemStyle HorizontalAlign="Right" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn  DataField="LastUpdatedBy" UniqueName="LastUpdatedBy"  ReadOnly="true" HeaderText="Người cập nhật">
                        <HeaderStyle HorizontalAlign="Center"  Width="80px" />
                        <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn  DataField="LastUpdatedDateTime" UniqueName="LastUpdatedDateTime"  ReadOnly="true" HeaderText="Ngày cập nhật">
                        <HeaderStyle HorizontalAlign="Center"  Width="80px" />
                        <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridBoundColumn>
                    <%--<telerik:GridTemplateColumn HeaderText="Chi tiết" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Button ID="btnEdit" CssClass="btnViewDetail" CommandArgument='<%# Eval("BannerID") %>'
                                CommandName="EditItem" runat="server"></asp:Button>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="50px" />
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle>
                    </telerik:GridTemplateColumn>--%>
                    <telerik:GridTemplateColumn HeaderText="Xóa" Visible=true HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Button ID="btnDelete" CssClass="btnX" CommandArgument='<%# Eval("BannerID") %>'
                                OnClientClick="return ConfirmOnDelete('Bạn chắc chắn muốn xóa không?')" CommandName="DeleteItem"
                                runat="server"></asp:Button>
                        </ItemTemplate>
                        <HeaderStyle Width="30px"/>
                            <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridTemplateColumn>
                </Columns>
                </MasterTableView>
            </telerik:radgrid>
        </div>
            <!--End Grid data-->        
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnSave" />

</Triggers>
</asp:UpdatePanel>
<div class="progressbar">
    <asp:UpdateProgress ID="up" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div class="bg">
                <div class="progress progress-striped active">
                    <div class="progress-bar" role="progressbar" aria-valuenow="45" aria-valuemin="0"
                        aria-valuemax="100" style="width: 100%">
                        <span class="sr-only">100% Complete</span>
                    </div>
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</div>
<script>
    function FormatNumber(obj) {

        var x;

        if (eval(obj))

            x = eval(obj).value;

        else

            x = obj;

        var num = x.replace(/$|,/g, '');

        if (isNaN(num)) { num = ""; }

        sign = (num == (num = Math.abs(num)));

        num = Math.floor(num * 100 + 0.50000000001);

        num = Math.floor(num / 100).toString();

        for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3) ; i++) {

            num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));

        }

        eval(obj).value = num;

    }
</script>